/**
 * @author wangze
 * @date 2018-09-14 14:01.
 **/

(function () {

    var defaultOpt = {
        name: null,
        title: null,
        subTitle: null,
        yTitle: null,
        dom: null,
        xData: null,
        dataLabels: {
            enabled: true,
            rotation: 0,
            color: '#FFFFFF',
            align: 'center',
            format: '{point.y:.1f}', // :.1f 为保留 1 位小数
            y: 30
        },
        data: [],
        height:260
    };

    function createPacInChart(option) {
        var opt = $.extend({}, defaultOpt, option)
        return new Highcharts.Chart({
            chart: {
                renderTo: opt.dom,
                type: 'column',
                height:opt.height
            },
            title: {
                text: opt.title
            },
            subtitle: {
                text: opt.subTitle
            },
            xAxis: {
                type: 'category',
                labels: {
                    rotation: 45  // 设置轴标签旋转角度
                },
                categories: opt.xData,
            },
            yAxis: {
                min: 0,
                title: {
                    text: opt.yTitle
                }
            },
            legend: {
                enabled: false
            },
            // tooltip: {
            //     pointFormat: '人口总量: <b>{point.y:.1f} 百万</b>'
            // },
            series: [{
                name: opt.name,
                data: opt.data,
                dataLabels: opt.dataLabels
            }]
        });
    }


    window.createPacInChart = createPacInChart

})()

